package io.adrainty.algorithm.diagram.chapter2;

import io.adrainty.algorithm.utils.ArrayUtils;

/**
 * <p>SelectSort</p>
 *
 * @author AdRainty
 * @version V1.0.0
 * @description 选择排序
 * @since 2025/7/28 11:33:56
 */

@SuppressWarnings("unused")
public class SelectSort {

    private SelectSort() {
    }

    public static void selectSort(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            int minIndex = i;
            for (int j = i + 1; j < arr.length; j++) {
                if (arr[j] < arr[minIndex]) {
                    minIndex = j;
                }
            }
            ArrayUtils.swap(arr, i, minIndex);
        }
    }

}
